package com.minelx.landisk.filesystem.core.provider;

import com.minelx.landisk.filesystem.core.Directory;
import com.minelx.landisk.filesystem.core.Locator;
import com.minelx.landisk.filesystem.core.values.PathDescription;

import java.nio.file.FileSystems;

import static com.minelx.landisk.filesystem.core.init.OpenPolicy.EXISTS;

public interface FS extends PathMethodProviderFactory {
	FS LOCAL_FS = fs(FileSystems.getDefault());

	FS NOT_IMPLEMENTED_FS = new NotImplementedFS();

	String schemaAndAuthority();

	static FS fs(java.nio.file.FileSystem fileSystem) {
		return new JavaFS(fileSystem);
	}

	static FS hdfs(org.apache.hadoop.fs.FileSystem fileSystem) {
		return new HDFS(fileSystem);
	}

	static FS notImplemented() {
		return NOT_IMPLEMENTED_FS;
	}

	static Locator local() {
		return new Locator(LOCAL_FS, PathDescription.root());
	}

	static Directory workingDir() {
		return local().dir(System.getProperty("user.dir").replace('\\', '/'), EXISTS);
	}
}
